<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>验证回文串 </title>
</head>
<body>
    <script>

        var isPalindrome = function(s) {
           
            var arr = s.toLocaleLowerCase().match(/[A-Za-z0-9]+/g)
            if(!arr) return true;
            var str = arr.join('');
            
            var i = 0;
            var j = str.length-1;
            while(j>i){
                if(str[i]==str[j]){
                    i++;
                    j--;
                }else {
                    return false;
                }
            }
            return true;
        };

    console.log(isPalindrome("ab_a"));   

    </script>
</body>
</html>